package org.apache.ws.security.message;

import org.apache.ws.security.message.token.OpenIDToken;
import org.w3c.dom.Document;
import org.w3c.dom.Element;


public class WSSecOpenIDToken extends WSSecBase {
	
	private OpenIDToken oit = null;	
	private String wrappedResponse = null;
	
	
		
	/**
     * Creates a OpenID token.
     * 
     * The method prepares and initializes a WSSec UsernameToken structure after
     * the relevant information was set. A Before calling
     * <code>prepare()</code> all parameters such as user, password,
     * passwordType etc. must be set. A complete <code>OpenIDToken</code> is
     * constructed.
     * 
     * @param doc The SOAP envelope as W3C document
     */
    public void prepare(Document doc) {
        oit = new OpenIDToken(doc);
        oit.setOpenID(user);
        oit.setResponseMessage(this.getWrappedResponse());        
    }

    /**
     * Appends the OpenIDToken element to the elements already in the
     * Security header.
     * 
     * The method can be called any time after <code>prepare()</code>.
     * This allows to insert the OpenIDToken element at any position in the
     * Security header.
     * 
     * @param secHeader The security header that holds the Signature element.
     */
    public void appendToHeader(WSSecHeader secHeader) {
        Element secHeaderElement = secHeader.getSecurityHeader();
        secHeaderElement.appendChild(oit.getElement());
    }

	public void setWrappedResponse(String wrappedResponse) {
		this.wrappedResponse = wrappedResponse;
	}

	public String getWrappedResponse() {
		return wrappedResponse;
	}
    
}
